package com.learn.file.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class StringUtil {

    private final static Logger log = LoggerFactory.getLogger(StringUtil.class);

    /**
     * 字符串 是否为空
     * @param str
     * @return true or false
     * @throws Exception
     */
    public static boolean isNotBank(String str) throws Exception {
        try {
            return str != null || str.length() > 0;
        } catch (Exception e) {
            log.error(e.getMessage());
            throw new Exception(e.getMessage());
        }
    }

    /**
     * 比较字符串内容 是否相同
     * @param strA
     * @param strB
     * @return
     * @throws Exception
     */
    public static boolean isEquals(String strA, String strB) throws Exception {
        if (isNotBank(strA) && isNotBank(strB)) {
            return strA.equals(strB);
        } else {
            log.info("比较字段存在为空的情况!!!");
            throw new Exception("比较字段存在为空的情况!!!");
        }
    }
}